# Lucid is (C) Copyright 2006-2007 by Infiscape Corporation
#
# This file is part of Lucid, a PyOpenSG example application.
#
# Lucid is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Lucid is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program.  If not, see <http://www.gnu.org/licenses/>.

# Main entry point for the application
#
import sys, os, os.path, time, traceback
pj = os.path.join

lucid_base_path = os.path.normpath(pj(os.path.dirname(__file__),'..'))
sys.path.insert(0,lucid_base_path)

sys.path.append(pj(lucid_base_path, "lucid/util/test_util"))
from PyQt4 import QtGui, QtCore, QtOpenGL

import lucid.util.plugin
   

def main():
   app = QtGui.QApplication(sys.argv)
   
   splash_map = QtGui.QPixmap("splash.png")
   splash = QtGui.QSplashScreen(splash_map)   
   splash.show()
   splash.showMessage("Bootstrapping system...")
   app.processEvents()

   # Load plugins
   def pluginProgressCB(percent, message):
      splash.showMessage("%s%% %s"%(percent,message))
      app.processEvents()
      time.sleep(0.5)
   
   plugin_mgr = lucid.util.plugin.PluginManager()
   plugin_mgr.scan(os.path.abspath("util/test_util/test_data/plugin_test_dir"),
                   pluginProgressCB)

   mainWin = QtGui.QMainWindow()
   mainWin.show()
   splash.finish(mainWin)
   splash = None

   sys.exit(app.exec_())

if __name__ == '__main__':
   main()
